<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MLang
 *
 * @author Administrator
 */
class MLang extends DB{
    
    public $lang=array();
    public $mlang_list=array();
    
    public function __construct()
    {
        $GLOBALS["DB"]->execute("set names utf8");
    }
    
    public function load($lanuage="en")
    {
        $L=$lanuage=="en"?"":",`".$lanuage."`";
        $re1=$GLOBALS['DB']->execute("select `id`,`en`{$L} from  `mlang` ");
        while(($data=mysql_fetch_assoc($re1))!==FALSE)
        {
            if($lanuage!="en")
            {
                $this->lang[$data['en']]=$data[$lanuage];
            }else
            {
                $this->lang[$data['en']]=$data['en'];
            }
        }
        
        $re2=$GLOBALS['DB']->execute("select `id`,`key`,`en`{$L} from  `long_mlang` ");
        while(($data=mysql_fetch_assoc($re2))!==FALSE)
        {
            array_push($this->mlang_list,$data['key']);
            if($lanuage!="en")
            {
                $this->lang[$data['key']]=$data[$lanuage];
            }else
            {
                $this->lang[$data['key']]=$data['en'];
            }
        }
    }
    
    public function get($key)
    {
        return $this->lang[$key];
    }
    
    
}

?>
